// 封装api方法
import myAxios from './myAxios'
import mockAxios from './mockAxios'
/**
 * 封装请求三级分类的方法
 * @returns promise
 */
export  const ReqCategoryList =()=> myAxios.get('/api/product/getBaseCategoryList')
/**
 * 封装请求轮播图的方法
 * @returns promise
 */
export const ReqSlideList = ()=> mockAxios.get('/slide')
/**
 * 封装请求楼层的方法
 * @returns promise
 */
export const ReqFloorList = ()=> mockAxios.get('/floor')
/**
 * 请求搜索数据的方法
 * @param {*} params 
 * @returns promise
 */
export const ReqSearchList = (params)=> myAxios.post('/api/list',params)
/**
 * 请求商品详情的方法
 * @param {*} id 
 * @returns promise
 */
export const ReqGoodsList = (id)=> myAxios.get(`/api/item/${id}`)

/**
 * 加入购物车的方法
 * @param {*} skuId 
 * @param {*} skuNum 
 * @returns null
 */
export const ReqaddToCart =(skuId,skuNum) => myAxios.post(`/api/cart/addToCart/${skuId}/${skuNum}`)

/**
 * 请求购物车数据的方法
 * @returns promise 
 */
export const ReqCartList = () => myAxios.get("/api/cart/cartList");

/**
 * 切换商品选中状态的方法
 * @param {*} skuID 
 * @param {*} isChecked 
 * @returns Promise null
 */
export const ReqOnecheckCart =(skuID,isChecked)=>myAxios.get(`/api/cart/checkCart/${skuID}/${isChecked}`)

/**
 * 购物车商品全选的方法
 * @param {*} params 
 * @returns Promise null
 */
export const ReqbatchCheckCart =(isChecked,skuIdList)=>myAxios.post(`/api/cart/batchCheckCart/${isChecked}`,skuIdList)

/**
 * 购物车删除单个商品
 * @param {*} skuId 
 * @returns Promise null
 */
export const ReqdeleteCart =(skuId)=> myAxios.delete(`/api/cart/deleteCart/${skuId}`)

/**
 * 批量删除购物车单个商品
 * @param {*} skuIdList 
 * @returns Promise null
 */
export const ReqbatchDeleteCart =(skuIdList)=>myAxios.post('/api/cart/batchDeleteCart',skuIdList)

/**
 * 用户注册
 * @param {*} params  {phone,password,code}
 * @returns Promise null
 */
export const ReqRegister =(params)=> myAxios.post('/api/user/passport/register',params)

/**
 * 获取验证码
 * @param {*} phone 
 * @returns Promise<string   验证码>
 */
export const ReqGetCode =(phone)=>myAxios.get(`/api/user/passport/sendCode/${phone}`)

/**
 * 登录功能
 * @param {*} params  {phone,password}
 * @returns Promise <token>
 */
export const ReqLogin =(params)=> myAxios.post('/api/user/passport/login',params)

/**
 * 获取用户信息
 * @returns Promise {}
 */
export const ReqgetUserInfo =()=> myAxios.get('/api/user/passport/auth/getUserInfo')

/**
 * 退出登录
 * @returns Promise null
 */
export const ReqLogout = ()=> myAxios.get('/api/user/passport/logout')

/**
 * 获取交易页购买商品列表信息
 * @returns Promise null
 */
export const ReqTrade = ()=> myAxios.get('/api/order/auth/trade')

/**
 * 获取模拟的地址数据 mock
 * @returns Promise null
 */
export const ReqAddress =()=> mockAxios.get('/address')

/**
 * 提交订单
 * @param {*} tradeNo 
 * @param {*} params 
 * @returns promise 订单编号
 */
export const ReqsubmitOrder = (tradeNo,params)=>myAxios.post(`/api/order/auth/submitOrder?tradeNo=${tradeNo}`,params)

/**
 * 获取订单支付信息
 * @param {*} orderId 
 * @returns promise
 */
export const ReqPay = (orderId)=>myAxios.get(`/api/payment/weixin/createNative/${orderId}`)

/**
 * 查询订单的支付状态
 * @param {*} orderId 
 * @returns promise null
 */
export const ReqPayStatus = (orderId)=> myAxios.get(`/api/payment/weixin/queryPayStatus/${orderId}`)

/**
 * 获取我的订单列表
 * @param {*} page 
 * @param {*} limit 
 * @returns promise
 */
export const ReqOrderList = (page,limit)=> myAxios.get(`/api/order/auth/${page}/${limit}`)